package com.business.socialcredit;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.frame.struts.ActionContext;
import com.frame.struts.BaseBean;
import com.utils.CommUtil;

public class JrjgsxdjForm extends BaseBean
{
    public JrjgsxdjForm()
    {
    }

    JrjgsxdjEntity jrjgsxdjEntity = new JrjgsxdjEntity();
    private String oldId="";

    public String addJrjgsxdj()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addJrjgsxdj()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        SocialCreditFactory factory = SocialCreditFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        jrjgsxdjEntity.setQyid( qyid );
        jrjgsxdjEntity.setOptdate( new Date() );
        jrjgsxdjEntity.setOptrid( CommUtil.getUserId( request ) );
        jrjgsxdjEntity.setXh( SocialCreditFactory.getNextXh( "qy_jrjgsxdj", qyid ) );
        try
        {
            if( factory.addJrjgsxdj( jrjgsxdjEntity ) )
            {
                System.out.println( "Enter addJrjgsxdj()" );
                response.sendRedirect( "/socialcredit/queryjrjgsxdj.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
        }
        return null;

    }

    public String editJrjgsxdj()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addJrjgsxdj()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        SocialCreditFactory factory = SocialCreditFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        jrjgsxdjEntity.setQyid( qyid );
        jrjgsxdjEntity.setOptdate( new Date() );
        jrjgsxdjEntity.setOptrid( CommUtil.getUserId( request ) );
        factory.delJrjgsxdj(qyid,jrjgsxdjEntity.getXh());
        try
        {
            if( factory.addJrjgsxdj( jrjgsxdjEntity ) )
            {
                System.out.println( "Enter editJrjgsxdj()" );
                response.sendRedirect( "/socialcredit/queryjrjgsxdj.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        return null;
    }
    
    public String getOldId(){
        return this.oldId;
    }
    public void setOldId(String oldId){
        this.oldId=oldId;
    }
    
    public String getQyid()
    {
        return jrjgsxdjEntity.getQyid();
    }

    public void setQyid( String qyid )
    {
        jrjgsxdjEntity.setQyid(qyid);
    }

    public int getXh()
    {
        return jrjgsxdjEntity.getXh();
    }

    public void setXh( int xh )
    {
        jrjgsxdjEntity.setXh( xh );
    }

    public String getMc()
    {
        return jrjgsxdjEntity.getMc();
    }

    public void setMc( String mc )
    {
        jrjgsxdjEntity.setMc( mc );
    }

    public String getXydj()
    {
        return jrjgsxdjEntity.getXydj();
    }

    public void setXydj( String xydj )
    {
        jrjgsxdjEntity.setXydj( xydj );
    }

    public String getYxq()
    {
        return jrjgsxdjEntity.getYxq();
    }

    public void setYxq( String yxq )
    {
        jrjgsxdjEntity.setYxq( yxq );
    }

    public double getSxed()
    {
        return jrjgsxdjEntity.getSxed();
    }

    public void setSxed( double sxed )
    {
        jrjgsxdjEntity.setSxed( sxed );
    }

    public String getOptrid()
    {
        return jrjgsxdjEntity.getOptrid();
    }

    public void setOptrid( String optrid )
    {
        jrjgsxdjEntity.setOptrid( optrid );
    }

    public Date getOptdate()
    {
        return jrjgsxdjEntity.getOptdate();
    }

    public void setOptdate( Date optdate )
    {
        jrjgsxdjEntity.setOptdate( optdate );
    }

    public String getRecstate()
    {
        return jrjgsxdjEntity.getRecstate();
    }

    public void setRecstate( String recstate )
    {
        jrjgsxdjEntity.setRecstate( recstate );
    }

    public String getRemark()
    {
        return jrjgsxdjEntity.getRemark();
    }

    public void setRemark( String remark )
    {
        jrjgsxdjEntity.setRemark( remark );
    }

}
